{extend name="public/base" /}
{block name="css"}
	<!-- webuploder -->
	<link rel="stylesheet" type="text/css" href="__PLUGINS__webuploader/webuploader.css">
    <!-- webuploder END -->
{/block}
{block name="content"}
       <section class="content-header">
<h1>
           添加栏目
<small>add term</small>
</h1>
{present name="$_GET['model_id']"}
<ol class="breadcrumb">
	<li><a href="{:U('Index/index')}"><i class="fa fa-dashboard"></i> 首页</a></li>
	{php}
	$postion = M('term')->where('id='.$_GET['parent_id'])->find();
	{/php}
	<li class="active">添加栏目</li>
	<li class="active">{$postion.name}</li>
</ol>
{else /}
<ol class="breadcrumb">
	<li><a href="{:U('Index/index')}"><i class="fa fa-dashboard"></i> 首页</a></li>
	<li class="active">添加栏目</li>
</ol>
 {/present}

</section>
<!-- Main content -->
<section class="content">
<div class="row">
	<div class="col-xs-12">
		<div class="box">
			<div class="box-header">
				<h3 class="box-title pad">
				<a href="{:U('Term/index')}" class="btn btn-primary">栏目管理</a>&nbsp;&nbsp;
				<a href="{:U('Term/addTerm')}" class="btn  btn-primary">添加栏目</a>&nbsp;&nbsp;
				<!-- <a href="{:U('Term/addTerm')}" class="btn  btn-primary">更新栏目缓存</a>&nbsp;&nbsp; -->
				</h3>
			</div>
			<form action="{:U('Term/addTerm')}" method="post">
				<div class="box-body" style="padding-top: 0">
					<!--输入框 -->
					
                  
				  {present name="$_GET['model_id']"}
                     <input type="hidden" name="parent_id" value="{$_GET['parent_id']}" >
					 				<div class="box-body pad" style="padding-top: 0;">
					  <label>所属模型</label>

							<select name="model_id" class="form-control">
								<option value="0">请选择模型</option>
								
								{foreach $modelList as $id => $model}
								<option value="{$id}" >{$model}</option>
								{/foreach}
								
							</select>
						</div>
					{else /}
					
				<div class="box-body pad" style="padding-top: 0;">
					  <label>所属模型</label>

							<select name="model_id" class="form-control">
								<option value="0">请选择模型</option>

								
								{foreach $modelList as $id => $model}
								<option value="{$id}" >{$model}</option>
								{/foreach}
								
							</select>
						</div>
						<div class="box-body pad">
						 <label>所属栏目：</label>
							<select name="parent_id" class="form-control">
								<option value="0">作为一级栏目</option>
					{volist name="all_term" id="data"}
								<option value="{$data.id}">{$data.name}</option>
					{/volist}
							</select>
						</div>
					
					 {/present}
				
					

					
					
					

					<div class="box-body pad">
					    <label>栏目名称:</label>
						<input class="form-control" name="name" placeholder="栏目名称">
					</div>
					<div class="box-body pad">
					    <label>栏目标识:</label>
						<input class="form-control" name="flag" placeholder="栏目标识">
					</div>
					<div class="box-body pad">
					     <label>栏目描述:</label>
						<textarea class="form-control" rows="4" name="description" placeholder="添加栏目描述"></textarea>
					</div>
					<div class="box-body pad">
			            是否在导航显示：			           
			           	<input type="radio" name="display_nav" value="1" checked="checked">是&nbsp;&nbsp;
						<input type="radio" name="display_nav" value="0">否&nbsp;&nbsp;
			           
						
					</div>
					<!--输入框 END-->
					
					<div class="box-header with-border">
						<h3 class="box-title" >SEO设置:</h3>
					</div>
					<br>
					<div class="box-body pad">
					    <label>栏目标题:</label>
						<input class="form-control" name="seo_title" placeholder="栏目标题">
					</div>
					<div class="box-body pad">
					    <label>关键词:</label>
						<input class="form-control" name="seo_keywords" placeholder="栏目关键词">
					</div>
					<div class="box-body pad">
					    <label>摘要:</label>
						<textarea class="form-control" rows="4" name="seo_description" placeholder="摘要描述"></textarea>
					</div>
				</div>
				<!-- END -->
				<div class="box-body pad">
					<div class="box-footer">
					<input type="submit" class="btn btn-block btn-primary" style="width:100px; border:none; margin-bottom:20px;" value="提交"/>
				</div>
				</div>
				
				
				<div style="clear:both">
				</div>
			</form>
		</div>
	</div>
</div>
</section>   
        
{/block}
{block name="script"}
    <!--有冲突暂时屏蔽，确认后再删除 <script type="text/javascript" src="__ADMINLTE__plugins/jQuery/jQuery-2.1.4.min.js"></script> -->
<script type="text/javascript" src="__PLUGINS__webuploader/webuploader.html5only.min.js"></script>
<script>
jQuery.fn.createUpload=function () {
    this.each(function() {
        var $list = $(this).find('.uploader-list'),
            pick  = '#'+$(this).find('.picker').attr('id'),
            name  = $(this).attr('name');
        var uploader = new WebUploader.Uploader({
            server: '{:U('AjaxUploads/uploads')}',
            pick: pick,
            // 其他配置项
            auto: true,
        });
        uploader.onFileQueued = function( file ) {
            $list.append( '<div id="' + file.id + '" class="item">' +
                '<h4 class="info">' + file.name + '</h4>' +
                '<p class="state">等待上传...</p>' +
            '</div>' );
        };
        // 文件上传过程中创建进度条实时显示。
        uploader.on( 'uploadProgress', function( file, percentage ) {
            console.log(file.name);
        });

        // 文件上传成功，给item添加成功class, 用样式标记上传成功。
        uploader.on( 'uploadSuccess', function( file, json ) {
                $( '#'+file.id ).html('<input type="hidden" name="'+name+'" value="'+json.savename+'">'+
                    '<image style="width:100px;height:100px" src="'+json.savepath+json.savename+'" />');
            alert(json._raw);
        })

        // 文件上传失败，现实上传出错。
        uploader.on( 'uploadError', function( file ) {
            var $li = $( '#'+file.id ),
                $error = $li.find('div.error');

            // 避免重复创建
            if ( !$error.length ) {
                $error = $('<div class="error"></div>').appendTo( $li );
            }

            $error.text('上传失败');
        });

    });
};
$(function() {
    $('.wu-example').createUpload();
});
</script>
{/block}
